/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Services;

import DAO.DAOFactory;
import DAO.Financial.DAOFinancial;
import DAO.Financial.MarketDAO;
import FinancialEntity.Market;
import VO.MarketVO;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;

/**
 *
 * @author Sebastian
 */
public class MarketService {
    
    public void createMarket(MarketVO marketVo, EntityManager em ){
        MarketDAO marketdao = (MarketDAO) DAOFactory.getDAOFinancial(DAOFactory.MARKET);
        marketdao.create(marketVo.toEntity(), em);
    }
    
    public List<MarketVO> getAllMarkets(EntityManager em){
        MarketDAO marketdao = (MarketDAO) DAOFactory.getDAOFinancial(DAOFactory.MARKET);
        List<Market> listaMercados = marketdao.findMarketEntities(em);
        List<MarketVO> listaVos = new ArrayList<MarketVO>();
        for (Market m:listaMercados){
            listaVos.add(m.toVO());
        }
        return listaVos;
    }
    
    
    
}
